// vPresent is an immersive presentation creation and display application.
// Copyright (C) 2007 by Infiscape Corporation
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

#ifndef _VP_RENDER_SERVER_H_
#define _VP_RENDER_SERVER_H_

#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>

#include <OpenSG/OSGConfig.h>
#include <OpenSG/OSGBaseTypes.h>
#include <OpenSG/OSGRenderTraversalAction.h>
#include <OpenSG/OSGClusterServer.h>

#include "Window.h"


namespace vp
{

class RenderServer : private boost::noncopyable
{
public:
   RenderServer(const std::string& name, vp::WindowPtr window,
               const std::string& connectionType,
               const std::string& address, const OSG::UInt32 servicePort,
               const std::string& serviceGroup, const bool exitOnError);

   void run();

private:
   void render();

   std::string   mName;
   vp::WindowPtr mWindow;
   std::string   mConnectionType;
   std::string   mAddress;
   OSG::UInt32   mServicePort;
   std::string   mServiceGroup;
   bool          mExitOnError;

   typedef boost::shared_ptr<OSG::RenderTraversalAction> RenderActionPtr;
   typedef boost::shared_ptr<OSG::ClusterServer>         ClusterServerPtr;

   RenderActionPtr            mRenderAction;
   ClusterServerPtr           mServer;
   boost::signals::connection mRenderConnection;
};

}


#endif /* _VP_RENDER_SERVER_H_ */
